package com.tank.KeyListener;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import com.tank.model.Tank;

/**
 * TODO
 *
 * @author chenwb
 * @since 2024/1/21 15:07
 */
public class BulletKeyListener extends KeyAdapter {

    private Tank tank;

    public BulletKeyListener(Tank tank) {
        this.tank = tank;
    }

    @Override
    public void keyPressed(KeyEvent e) {
        int keyCode = e.getKeyCode();
        if (KeyEvent.VK_SPACE == keyCode) {
            tank.fire();
        }

    }
}
